<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/content/variable.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<%@ include file="/content/head.jsp"%>
</head>
<body>
    <div class="row">
        <div class="col-md-12">
            <div class="box box-info">
                <div class="box-header with-border">
                    <h3 class="box-title">修改私播</h3>
                </div>
               <form id="privatePlayAdd" class="form-horizontal" role="form" onsubmit="javascript:savePrivatePlay();">
                    <div class="box-body">
                        <div class="form-group">
                            <label for="room_time" class="col-sm-2 control-label">用户名：</label>
                            <div class="col-sm-8 ">
                                <input type="text" id="room_time" class="form-control" name="room_time"
                                       value="${obj.room_time}" placeholder="用户名">
                            </div>
                        </div>
                        <br>
                        <div class="form-group">
                            <label for="live_number" class="col-sm-2 control-label">在线人数：</label>
                            <div class="col-sm-8 ">
                                <input type="text" id="live_number" class="form-control" name="live_number"
                                       value="${obj.live_number}" placeholder="在线人数">
                            </div>
                        </div>
                        <br>
                        <div class="form-group">
                            <label for="avatar" class="col-sm-2 control-label">头像：</label>
                            <div class="col-md-8">
								<input type="file" class="file-loading" id="anchorHeadImgFile" accept="image/*">
								<input type="text" value="${obj.avatar}" class="form-control input-sm" id="anchorHeadImgUrl" name="avatar"> 
							</div>
							<div class="col-sm-2">
								<span class="help-inline" style="color: #a94442"></span>
							</div>
                        </div>
                        <br>
                        <div class="form-group">
                            <label for="live_address" class="col-sm-2 control-label">语音地址：</label>
                             <div class="col-md-8">
								<input type="file" class="file-loading" id="addressFile" accept="*/*">
								<input type="text" value="${obj.live_address}" class="form-control input-sm" id="addressUrl" name="live_address"> 
							</div>
							<div class="col-sm-2">
								<span class="help-inline" style="color: #a94442"></span>
							</div>
                        </div>
                        <br>
                        <input type="hidden" name ="id" id="id" value="${obj.id}"/>
                        <div class="col-md-offset-5 col-md-9">
                            <button type="submit" class="btn btn-success">确定</button>
                        </div>
                    </div>
                </form>
            </div>

        </div>
    </div>
    <!-- /.row -->
<%@ include file="/content/js.jsp"%>
<script type="text/javascript">
//头像上传
$("#anchorHeadImgFile").fileinput({
	uploadUrl:"<%=path%>/privatePlay/uploadClassifyImg",
    browseClass: "btn btn-primary",
    enctype: 'multipart/form-data',
    autoReplace:true,
    dropZoneEnabled:false,
    browseLabel: "上传",
    showCaption: false,
    showRemove: false,
    showUpload: true,
    showZoom:false,
    maxFileCount:1, ////表示允许同时上传的最大文件个数
    allowedFileTypes:["image"], //文件的选择类型[‘image’, ‘html’, ‘text’, ‘video’, ‘audio’, ‘flash’, ‘object’]
    previewSettings:{
    	image: {width: "auto", height: "100px"},
    },
});
$('#anchorHeadImgFile').on('fileuploaded', function(event, data, previewId, index) {
	var path = data.response.initialPreviewConfig[0].extra.path;
    $("#anchorHeadImgUrl").val(path);
});
$('#anchorHeadImgFile').on('filedeleted', function(event,key,jqXHR,data) {
	if($("#anchorHeadImgUrl").val()==data.path)
		$("#anchorHeadImgUrl").val('');
}); 
//语音上传
$("#addressFile").fileinput({
	uploadUrl:"<%=path%>/privatePlay/uploadClassifyAudio",
    browseClass: "btn btn-primary",
//     enctype: 'multipart/form-data',
    autoReplace:true,
    dropZoneEnabled:false,
    browseLabel: "上传",
    showCaption: false,
    showRemove: false,
    showUpload: true,
    showZoom:false,
    maxFileCount:1, ////表示允许同时上传的最大文件个数
//     allowedFileTypes:["audio"], //文件的选择类型[‘image’, ‘html’, ‘text’, ‘video’, ‘audio’, ‘flash’, ‘object’]
    maxFileSize:0,//单位为kb，如果为0表示不限制文件大小
    previewSettings:{
//			object: {width: "auto", height: "100px"},
 	   	type:"audio",
 	   	audio: {width: "auto", height: "100px"},
   },
});
$('#addressFile').on('fileuploaded', function(event, data, previewId, index) {
	var path = data.response.initialPreviewConfig[0].extra.path;
    $("#addressUrl").val(path);
});
$('#addressFile').on('filedeleted', function(event,key,jqXHR,data) {
	if($("#addressUrl").val()==data.path)
		$("#addressUrl").val('');
}); 

	function savePrivatePlay(){
		var room_time = $("#room_time").val();
		var live_number = $("#live_number").val();
		var avatar = $("#anchorHeadImgUrl").val();
		var live_address = $("#addressUrl").val();
		var id = $("#id").val();
		$.ajax({
			type:"post",
			async: false,
			url:"<%=path%>/privatePlay/alertSavePrivatePlay",
			data:{id:id,
				room_time:room_time,
				live_number:live_number,
				avatar:avatar,
				live_address:live_address},
			dataType:"json",
			success: function(data){
				if (data.missage == "success") {
                 modalMsg("修改成功", "success");
                 window.parent.location.reload();
                 var index = parent.layer.getFrameIndex(window.name);
                 parent.layer.close(index);
             }else if(data.missage == "error"){
             	 modalMsg("修改失败", "error");
             }else{
             	 modalMsg("更新失败", "error");
             }
			}
		});
	}
    
</script>
</body>
</html>